<template>
	<view>
		<u-navbar title="系统消息" @rightClick="rightClick" :autoBack="true">	</u-navbar>
			<view class="conn">
				<u-cell-group v-if="show">
					<u-cell :value="item.createTime" v-for="item in list" :key="item.id" :label="item.content"
						@click="kan(item)">
						<u-icon :color="item.status==='0'?'#e82315':'#bab3a6'" slot="icon" size="25"
							name="chat"></u-icon>
					</u-cell>
				</u-cell-group>
				<view>
					<u-modal :show="showmodal" :content='item.content' @confirm="confirm()"></u-modal>
				</view>
				<u-empty mode="search" icon="http://cdn.uviewui.com/uview/empty/search.png" v-if="!show">
				</u-empty>
			</view>
	</view>
</template>
<script>
	// import navbox from '../components/navbox/navbox.vue'
	export default {
		data() {
			return {
				showmodal: false,
				show: true,
				user: uni.getStorageSync("loginUser"),
				list: [],
				item: {}
			}
		},
		onLoad() {
			var isLogin=this.$isLogin()
			if(isLogin){
				this.getlist()
			}
		},
		methods: {
			rightClick() {
				uni.navigateBack()
				console.log('rightClick');
			},
			leftClick() {
				uni.navigateBack()
				console.log('leftClick');
			},
			async confirm() {
				if (this.item.status === "0") {
					const res = await this.$myRuquest({
						url: '/font/read?id=' + this.item.id
					})
					this.getlist()
				}
				this.showmodal = false
			},
			kan(item) {
				this.item = item
				this.showmodal = true
			},
			async getlist() {
				// if (this.user === null || this.user === '') {
				// 	this.show = false
				// 	return uni.showToast({
				// 		title: "请先登录",
				// 		icon: 'none'
				// 	})
				// }
				const res = await this.$myRuquest({
					url: '/font/messageList?userId=1'
				})
				console.log(res)
				this.list = res.data.data
			}
		}
	}
</script>
<style>
	.conn {
		margin-top: 180rpx;
	}

	.box {
		width: 100px;
		height: 100px;
		background-color: #909193;
		border-radius: 15px;
	}
</style>